[id].vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div id="newsList">
  3. <!-- 头部 -->
  4. <templateHead v-if="skinId <= 4"></templateHead>
  5. <!-- 皮肤5头部 -->
  6. <templateHead5 v-if="skinId == 5"></templateHead5>
  7. <!-- 皮肤6头部 -->
  8. <templateHead6 v-if="skinId == 6"></templateHead6>
  9. <!-- 皮肤7头部 -->
  10. <templateHead7 v-if="skinId==7"></templateHead7>
  11. <!-- 菜单 -->
  12. <templateMenu v-if="skinId <= 4"></templateMenu>
  13. <!-- 皮肤5菜单 -->
  14. <templateMenu5 v-if="skinId >= 5"></templateMenu5>
  15. <div v-for="(item, index) in templateData" :key="index">
  16. <!--1.广告通栏-->
  17. <div v-if="item.sectorName == 'adSector'">
  18. <templateAd :skinId="skinId" :adData="adData" :adTag="item.ad.ad_tag"></templateAd>
  19. </div>
  20. <!-- 2.搜索列表 -->
  21. <div v-if="item.sectorName == 'searchListSector'">
  22. <templateSearch :skinId="skinId" :templateData="item.componentList"></templateSearch>
  23. </div>
  24. <!-- 3.皮肤5搜索列表 -->
  25. <div v-if="item.sectorName == 'searchListpicSector'">
  26. <templateSearchListpic :skinId="skinId" :templateData="item.componentList"></templateSearchListpic>
  27. </div>
  28. <!-- 3.皮肤6搜索列表 -->
  29. <div v-if="item.sectorName == 'SearchbigListSector'">
  30. <templateSearchListbig :skinId="skinId" :templateData="item.componentList"></templateSearchListbig>
  31. </div>
  32. <!-- 4.皮肤7搜索列表 -->
  33. <div v-if="item.sectorName == 'SevenSearchbigListscSector'">
  34. <templateSevenSearchbigListscSector :skinId="skinId" :templateData="item.componentList"></templateSevenSearchbigListscSector>
  35. </div>
  36. </div>
  37. <!-- 底部 -->
  38. <templateFoot v-if="skinId <= 4"></templateFoot>
  39. <!-- 皮肤5底部 -->
  40. <templateFoot1 v-if="skinId==5||skinId==6"></templateFoot1>
  41. <!-- 皮肤7底部 -->
  42. <templateFoot2 v-if="skinId==7"></templateFoot2>
  43. </div>
  44. </template>
  45. <script setup lang="ts">
  46. //0.加载全局模板组件 start---------------------------------------->
  47. //0.1 全局通栏
  48. import templateHead from '@/components/template/sector/head/1200x200/1.vue'
  49. import templateHead5 from '@/components/template/sector/head/1200x250/1.vue'
  50. import templateHead6 from '@/components/template/sector/head/1200x250/6.vue'
  51. import templateHead7 from '@/components/template/sector/head/1200x250/7.vue'
  52. import templateMenu from '@/components/template/sector/menu/1200x130/1.vue'
  53. import templateMenu5 from '@/components/template/sector/menu/1200x187/1.vue'
  54. import templateFoot from '@/components/template/sector/foot/1200x580/1.vue'
  55. import templateFoot1 from '@/components/template/sector/foot/1200x680/1.vue'
  56. import templateFoot2 from '@/components/template/sector/foot/1200x700/1.vue'
  57. //0.2.1 广告组件
  58. import templateAd from '@/components/template/sector/body/ad/1200x90/1.vue'
  59. //0.2.2 搜索组件
  60. import templateSearch from '@/components/template/sector/body/search/list/1200x1300/1.vue'
  61. //0.2.3 搜索列表图片组件
  62. import templateSearchListpic from '@/components/template/sector/body/search/list/1200x2250/1.vue'
  63. //0.2.4 搜索列表图片组件
  64. import templateSearchListbig from '~/components/template/sector/body/search/list/1200x1530/6/1.vue'
  65. //0.2.5 皮肤7搜索列表
  66. import templateSevenSearchbigListscSector from '~/components/template/sector/body/search/list/1200x1720/1.vue'
  67. //0.加载全局模板组件 end---------------------------------------->
  68. //1.获得基本信息单元 start---------------------------------------->
  69. //1.1获得页面依赖
  70. import { ref, onMounted } from 'vue';
  71. //1.2获得pinia源
  72. import { useTemplateBaseStore } from '@/stores/templateBase'
  73. const templateBaseStore: any = useTemplateBaseStore()
  74. //1.3获得该页的皮肤id - 在每个组件中也是同样的获得方法
  75. const skinId = ref<number>(0)
  76. const websiteId = ref<number>(0)
  77. //1.4获得站点基本信息
  78. const responseStatus: any = await requestDataPromise('/web/getWebsiteAllinfo', {
  79. method: 'GET',
  80. query: {
  81. 'link_textnum': 24,
  82. 'link_imgnum': 18,
  83. 'link_footnum': 4
  84. },
  85. });
  86. if (responseStatus.code == 200) {
  87. if (responseStatus.data.website_foot.foot_info.status == 1) {
  88. //网站模板已停用,直接转入404页面
  89. navigateTo('/error?findPage=index')
  90. } else {
  91. //0.3.1设置站点基本信息
  92. templateBaseStore.setWebSiteInfo(responseStatus.data)
  93. websiteId.value = responseStatus.data.website_head.id;//获得网站id
  94. //0.3.2设置皮肤id
  95. skinId.value = templateBaseStore.webSiteInfo.website_foot.foot_info.template_id;
  96. console.log("当前的网站id:" + responseStatus.data.website_head.id)
  97. //0.3.3设置seo信息
  98. let seoTitle = templateBaseStore.webSiteInfo.website_head.title;
  99. let seoDescription = templateBaseStore.webSiteInfo.website_head.description;
  100. let seoKeywords = templateBaseStore.webSiteInfo.website_head.keywords;
  101. let seoSuffix = templateBaseStore.webSiteInfo.website_head.suffix;
  102. let seoName = templateBaseStore.webSiteInfo.website_head.website_name;
  103. useHead({
  104. title: seoTitle + "_" + seoSuffix,
  105. meta: [
  106. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  107. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 }
  108. ]
  109. });
  110. }
  111. }
  112. //1.获得基本信息单元 end---------------------------------------->
  113. //2.页面数据 start---------------------------------------->
  114. //2.1获得页面数据
  115. const response = await requestDataPromise('/client/indexData', {
  116. method: 'POST',
  117. body: {
  118. 'website_id': websiteId.value,
  119. 'getpage': 'search'
  120. },
  121. });
  122. //页面数据
  123. const templateData = response.data.template.search;
  124. //是否启用搜索功能
  125. templateBaseStore.setIsSearch(response.data.isSearch)
  126. console.log(templateData)
  127. //广告数据
  128. const adData = ref<any[]>([]);
  129. adData.value.push(response.data.ad.top)
  130. for (let item of response.data.ad.search) {
  131. adData.value.push(item)
  132. }
  133. templateBaseStore.setAdList(adData.value)
  134. //2.页面数据 end---------------------------------------->
  135. </script>
  136. <style lang="less" scoped></style>